package com.robert.demo.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.robert.common.commonutil.bean.vo.ResultData;
import com.robert.common.commonutil.util.DateUtils;
import com.robert.demo.common.aop.ValidateResult;
import com.robert.demo.entity.OptLogInfo;
import com.robert.demo.service.IOptLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;

/**
 * OptLogServiceImpl:
 *
 * @author zhaoshengtao
 * @date 2024/01/05
 */
@Service
@Slf4j
public class OptLogServiceImpl implements IOptLogService {


    @Override
    public void insertInfo(OptLogInfo info) {
        log.info("执行入库，log="+ info.toString());
    }

    @Override
    @ValidateResult(value = "logResultValidator", paramType = OptLogInfo.class)
    public ResultData queryList(OptLogInfo info) {
        ArrayList<OptLogInfo> infos = new ArrayList<>();
        infos.add(OptLogInfo.builder().id(1L).name("测试").userId(1).state("1").result("success").createTime(new Date()).build());
        infos.add(OptLogInfo.builder().id(2L).name("测试2").userId(2).state("1").result("success").createTime(new Date()).build());
        return ResultData.success(infos);
    }


    private int getTableName(){
        String date = DateUtils.getDate(DateUtils.YYYYMMDD);
        return Integer.parseInt(date)%5;
    }

}
